package com.meilai.project.mapper.system;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.meilai.project.entity.system.Router;
import com.meilai.project.vo.system.RightVO;
import com.meilai.project.vo.system.RouterVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 张驰
 * @date 2020/9/10 17:25
 */
@Mapper
public interface RouterMapper extends BaseMapper<Router> {
    RouterVO getIndexPageByRouterId(@Param("id") Long id);

    List<RightVO> getRightVOs(@Param("ids") List<Long> ids);

    @Select("select * from router r\n" +
            "left join router_roledepartment_relation rrr on r.id=rrr.router_id\n" +
            "left join role_department_relation rdr on rrr.role_department_id=rdr.id\n" +
            "left join user_roledepartment_relation urr on rdr.id=urr.role_department_id\n" +
            "where urr.user_id=#{userId} and r.type=#{type}")
    List<Router> findByUserId(@Param("userId")long userId,@Param("type")int type);

    @Select("select * from router where type=#{type}")
    List<Router> findByType(@Param("type")int type);
}
